#!/bin/bash

# directory
bin_link_dir="/usr/bin"
lib_link_dir="/usr/lib"
install_main_dir="/usr/local/kaiwudb"
bin_dir="${install_main_dir}/bin"
lib_dir="${install_main_dir}/lib"

# Execute the commands with sudo perimission
csudo=""
if command -v sudo > /dev/null; then
    csudo="sudo "
fi

# Remove link
${csudo}rm -f ${lib_link_dir}/libcommon.so

# Make link
${csudo}ln -s ${lib_dir}/libcommon.so ${lib_link_dir}/libcommon.so

${csudo}echo "/usr/local/kaiwudb/lib" > /etc/ld.so.conf.d/kaiwudb.conf
${csudo}/sbin/ldconfig &> /dev/null
